<?php

namespace backend\modules\datainfo\models;

use Yii;

/**
 * This is the model class for table "click_info".
 *
 * @property string $click_info_id
 * @property integer $created_at
 * @property string $ip
 * @property string $openid
 */
class ClickInfo extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'click_info';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['created_at'], 'required'],
            [['created_at'], 'integer'],
            [['ip'], 'string', 'max' => 15],
            [['openid'], 'string', 'max' => 45],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'click_info_id' => Yii::t('app', 'Click Info ID'),
            'created_at' => Yii::t('app', 'Created At'),
            'ip' => Yii::t('app', 'Ip'),
            'openid' => Yii::t('app', 'Openid'),
        ];
    }

    /**
     * @inheritdoc
     * @return \backend\modules\datainfo\models\query\ClickInfoQuery the active query used by this AR class.
     */
    public static function find()
    {
        return new \backend\modules\datainfo\models\query\ClickInfoQuery(get_called_class());
    }

    /**
     *
     */
    public static function bClickInfo()
    {
        $model = new ClickInfo();
        $model->created_at = time();
        $model->openid = Yii::$app->session->get('openid');
        $model->save();
    }
}
